## API Report File for "@backstage/plugin-search-backend-module-pg"

> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).

```ts
import { BatchSearchEngineIndexer } from '@backstage/plugin-search-backend-node';
import { Config } from '@backstage/config';
import { IndexableDocument } from '@backstage/plugin-search-common';
import { IndexableResultSet } from '@backstage/plugin-search-common';
import { Knex } from 'knex';
import { Logger } from 'winston';
import { PluginDatabaseManager } from '@backstage/backend-common';
import { SearchEngine } from '@backstage/plugin-search-common';
import { SearchQuery } from '@backstage/plugin-search-common';

// @public
export type ConcretePgSearchQuery = {
  pgQuery: PgSearchQuery;
  pageSize: number;
};

// @public (undocumented)
export class DatabaseDocumentStore implements DatabaseStore {
  constructor(db: Knex);
  // (undocumented)
  completeInsert(tx: Knex.Transaction, type: string): Promise<void>;
  // (undocumented)
  static create(
    database: PluginDatabaseManager,
  ): Promise<DatabaseDocumentStore>;
  // (undocumented)
  getTransaction(): Promise<Knex.Transaction>;
  // (undocumented)
  insertDocuments(
    tx: Knex.Transaction,
    type: string,
    documents: IndexableDocument[],
  ): Promise<void>;
  // (undocumented)
  prepareInsert(tx: Knex.Transaction): Promise<void>;
  // (undocumented)
  query(
    tx: Knex.Transaction,
    searchQuery: PgSearchQuery,
  ): Promise<DocumentResultRow[]>;
  // (undocumented)
  static supported(knex: Knex): Promise<boolean>;
  // (undocumented)
  transaction<T>(fn: (tx: Knex.Transaction) => Promise<T>): Promise<T>;
}

// @public (undocumented)
export interface DatabaseStore {
  // (undocumented)
  completeInsert(tx: Knex.Transaction, type: string): Promise<void>;
  // (undocumented)
  getTransaction(): Promise<Knex.Transaction>;
  // (undocumented)
  insertDocuments(
    tx: Knex.Transaction,
    type: string,
    documents: IndexableDocument[],
  ): Promise<void>;
  // (undocumented)
  prepareInsert(tx: Knex.Transaction): Promise<void>;
  // (undocumented)
  query(
    tx: Knex.Transaction,
    pgQuery: PgSearchQuery,
  ): Promise<DocumentResultRow[]>;
  // (undocumented)
  transaction<T>(fn: (tx: Knex.Transaction) => Promise<T>): Promise<T>;
}

// @public (undocumented)
export interface DocumentResultRow {
  // (undocumented)
  document: IndexableDocument;
  // (undocumented)
  highlight: IndexableDocument;
  // (undocumented)
  type: string;
}

// @public (undocumented)
export class PgSearchEngine implements SearchEngine {
  // @deprecated
  constructor(databaseStore: DatabaseStore, config: Config, logger?: Logger);
  // @deprecated (undocumented)
  static from(options: {
    database: PluginDatabaseManager;
    config: Config;
    logger?: Logger;
  }): Promise<PgSearchEngine>;
  // (undocumented)
  static fromConfig(
    config: Config,
    options: PgSearchOptions,
  ): Promise<PgSearchEngine>;
  // (undocumented)
  getIndexer(type: string): Promise<PgSearchEngineIndexer>;
  // (undocumented)
  query(query: SearchQuery): Promise<IndexableResultSet>;
  // (undocumented)
  setTranslator(translator: PgSearchQueryTranslator): void;
  // (undocumented)
  static supported(database: PluginDatabaseManager): Promise<boolean>;
  // (undocumented)
  translator(
    query: SearchQuery,
    options: PgSearchQueryTranslatorOptions,
  ): ConcretePgSearchQuery;
}

// @public (undocumented)
export class PgSearchEngineIndexer extends BatchSearchEngineIndexer {
  constructor(options: PgSearchEngineIndexerOptions);
  // (undocumented)
  finalize(): Promise<void>;
  // (undocumented)
  index(documents: IndexableDocument[]): Promise<void>;
  // (undocumented)
  initialize(): Promise<void>;
}

// @public (undocumented)
export type PgSearchEngineIndexerOptions = {
  batchSize: number;
  type: string;
  databaseStore: DatabaseStore;
  logger?: Logger;
};

// @public
export type PgSearchHighlightOptions = {
  useHighlight?: boolean;
  maxWords?: number;
  minWords?: number;
  shortWord?: number;
  highlightAll?: boolean;
  maxFragments?: number;
  fragmentDelimiter?: string;
  preTag: string;
  postTag: string;
};

// @public
export type PgSearchOptions = {
  database: PluginDatabaseManager;
  logger?: Logger;
};

// @public (undocumented)
export interface PgSearchQuery {
  // (undocumented)
  fields?: Record<string, string | string[]>;
  // (undocumented)
  limit: number;
  // (undocumented)
  offset: number;
  // (undocumented)
  options: PgSearchHighlightOptions;
  // (undocumented)
  pgTerm?: string;
  // (undocumented)
  types?: string[];
}

// @public
export type PgSearchQueryTranslator = (
  query: SearchQuery,
  options: PgSearchQueryTranslatorOptions,
) => ConcretePgSearchQuery;

// @public
export type PgSearchQueryTranslatorOptions = {
  highlightOptions: PgSearchHighlightOptions;
};

// @public (undocumented)
export interface RawDocumentRow {
  // (undocumented)
  document: IndexableDocument;
  // (undocumented)
  hash: unknown;
  // (undocumented)
  type: string;
}
```
